package com.none.web.model;

import java.sql.Timestamp;

import javax.persistence.OrderBy;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * Activity  model,useing mapping database
 * @author Dave 20141106
 */
@Entity
@Table(name = "t_activity")
public class TActivity implements java.io.Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
      private String id;//UUID
      private String subject;//主题
      private Timestamp startTime;//开始时间
      private Timestamp endTime;//结束时间
      private String venue;//活动发生地点
      private String banner;//活动标示
      private String briefContent;//摘要内容160个字
      private String description;//活动描述
      private Integer limitNum;//报名活动人数限制
      private Integer joinType;//参与类型，0为先到先参与，1为由组织决定谁可以参与。
      private Timestamp deadline;//报名截止日期
      private Integer status;//活动状态,-1是拒绝,0是草稿,1是等待审核,2审核通过,3是活动进行中,4是活动结束/关闭
      private TUser createUser;//创建人
      private Timestamp createTime;//创建时间

      private TUser editUser;//修改人
      private Timestamp editTime;//修改时间
      private TUser reviewUser;//审核人
      private Timestamp reviewTime;//审核时间
      private String push;//是否推送，push推送，空不推送
      
      private Timestamp submit_time;//提交时间
      private String submit_user_id;//提交人Id
      private String submit_user_name;//提交人姓名
      private String pushInfo;//编辑后的推送信息

      
      private String enroll_need;//用户报名需要填写的字段
      private Set<TActivityAppUser> appUsers=new HashSet<TActivityAppUser>();//报名人员
      private Set<TTags> tags=new HashSet<TTags>();//标签
      private String types;
  	  private List<TActivityImage> imageList = new ArrayList<TActivityImage>(0);//add by william 2014-12-11
      private String Flag;
      private Integer push_count;//总过推送过多少次
      
      private Integer likeAmount ;
  	  private List<TComments> commentList = new ArrayList<TComments>(0);
  	  private Integer browseTimes;//总浏览量（同一人浏览多次算一次）
	  private Integer allBrowseTimes;//总浏览量（同一人浏览几次算几次）
  	  private boolean isLike;
  	  private Integer commentAmount;
  	  
  	  private String videoFlag;//如果description中包含视频信息，设置为video,否则为notvideo
  	  private String haveNowTagFlag;//是否包含now标签
  	  private String finishFlag;//活动是否已经结束
  	  private String regFlag;//某个用户是否已经报过名
  
	// Property accessors
  	@Id
  	@Column(name = "id", unique = true, nullable = false, length =32)
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	
	@Column(name = "subject", length = 200)
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	@Column(name = "start_time", nullable = false, length = 19)
	public Timestamp getStartTime() {
		return startTime;
	}
	public void setStartTime(Timestamp startTime) {
		this.startTime = startTime;
	}
	@Column(name = "end_time")
	public Timestamp getEndTime() {
		return endTime;
	}
	public void setEndTime(Timestamp endTime) {
		this.endTime = endTime;
	}
	@Column(name = "venue" , length = 100)
	public String getVenue() {
		return venue;
	}
	public void setVenue(String venue) {
		this.venue = venue;
	}
	@Column(name = "banner",  length = 300)
	public String getBanner() {
		return banner;
	}
	public void setBanner(String banner) {
		this.banner = banner;
	}
	@Column(name = "brief_content", length = 200)
	public String getBriefContent() {
		return briefContent;
	}
	public void setBriefContent(String briefContent) {
		this.briefContent = briefContent;
	}
	@Column(name = "description")
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	@Column(name = "limitNum")
	public Integer getLimitNum() {
		return limitNum;
	}
	public void setLimitNum(Integer limitNum) {
		this.limitNum = limitNum;
	}
	@Column(name = "join_type")
	public Integer getJoinType() {
		return joinType;
	}
	public void setJoinType(Integer joinType) {
		this.joinType = joinType;
	}
	@Column(name = "deadline")
	public Timestamp getDeadline() {
		return deadline;
	}
	public void setDeadline(Timestamp deadline) {
		this.deadline = deadline;
	}
	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "create_userid")
	public TUser getCreateUser() {
		return createUser;
	}
	public void setCreateUser(TUser createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_time")
	public Timestamp getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "edit_userid")
	public TUser getEditUser() {
		return editUser;
	}
	public void setEditUser(TUser editUser) {
		this.editUser = editUser;
	}
	@Column(name = "edit_time")
	public Timestamp getEditTime() {
		return editTime;
	}
	public void setEditTime(Timestamp editTime) {
		this.editTime = editTime;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "review_userid")
	public TUser getReviewUser() {
		return reviewUser;
	}
	public void setReviewUser(TUser reviewUser) {
		this.reviewUser = reviewUser;
	}
	@Column(name = "review_time")
	public Timestamp getReviewTime() {
		return reviewTime;
	}
	public void setReviewTime(Timestamp reviewTime) {
		this.reviewTime = reviewTime;
	}


	@Column(name = "enroll_need")
	public String getEnroll_need() {
		return enroll_need;
	}
	public void setEnroll_need(String enroll_need) {
		this.enroll_need = enroll_need;
	}
	//activity table and enrol table mapping
	@OneToMany(mappedBy = "activity")
	@OrderBy("enroll_time DESC")
	public Set<TActivityAppUser> getAppUsers() {
		return appUsers;
	}
	public void setAppUsers(Set<TActivityAppUser> appUsers) {
		this.appUsers = appUsers;
	}
	
	
	//activity and tags    of     mapping
	
	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, fetch = FetchType.LAZY)
	@OrderBy("tagId ASC")
	@JoinTable(name = "t_activity_tag", joinColumns = { @JoinColumn(name = "activity_id", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "tag_id", updatable = false) })
	public Set<TTags> getTags() {
		return tags;
	}
	public void setTags(Set<TTags> tags) {
		this.tags = tags;
	}
	@Transient
	public String getTypes() {
		return types;
	}
	public void setTypes(String types) {
		this.types = types;
	}
	@Transient
	public List<TActivityImage> getImageList() {
		return imageList;
	}
	public void setImageList(List<TActivityImage> imageList) {
		this.imageList = imageList;
	}
	@Transient
	public String getFlag() {
		return Flag;
	}
	public void setFlag(String flag) {
		Flag = flag;
	}
	@Transient
	public Integer getLikeAmount() {
		return likeAmount;
	}
	public void setLikeAmount(Integer likeAmount) {
		this.likeAmount = likeAmount;
	}
	@Transient
	public List<TComments> getCommentList() {
		return commentList;
	}
	public void setCommentList(List<TComments> commentList) {
		this.commentList = commentList;
	}
	@Transient
	public Integer getBrowseTimes() {
		return browseTimes;
	}
	public void setBrowseTimes(Integer browseTimes) {
		this.browseTimes = browseTimes;
	}
	@Transient
	public boolean isLike() {
		return isLike;
	}
	public void setLike(boolean isLike) {
		this.isLike = isLike;
	}
	@Transient
	public Integer getCommentAmount() {
		return commentAmount;
	}
	public void setCommentAmount(Integer commentAmount) {
		this.commentAmount = commentAmount;
	}
	
	@Transient
	public Integer getAllBrowseTimes() {
		return allBrowseTimes;
	}
	public void setAllBrowseTimes(Integer allBrowseTimes) {
		this.allBrowseTimes = allBrowseTimes; 
	}
	/**
	 * @return the push_count
	 */
	@Column(name = "push_count")
	public Integer getPush_count() {
		return push_count;
	}
	/**
	 * @param push_count the push_count to set
	 */
	public void setPush_count(Integer push_count) {
		this.push_count = push_count;
	}
	/**
	 * @return the push
	 */
	@Column(name = "push")
	public String getPush() {
		return push;
	}
	/**
	 * @param push the push to set
	 */
	public void setPush(String push) {
		this.push = push;
	}
	
	@Column(name = "submit_time")
	public Timestamp getSubmit_time() {
		return submit_time;
	}

	public void setSubmit_time(Timestamp submit_time) {
		this.submit_time = submit_time;
	}
	@Column(name = "submit_user_id")
	public String getSubmit_user_id() {
		return submit_user_id;
	}

	public void setSubmit_user_id(String submit_user_id) {
		this.submit_user_id = submit_user_id;
	}
    @Transient
	public String getSubmit_user_name() {
		return submit_user_name;
	}

	public void setSubmit_user_name(String submit_user_name) {
		this.submit_user_name = submit_user_name;
	}
	@Column(name = "pushInfo")
	public String getPushInfo() {
		return pushInfo;
	}
	public void setPushInfo(String pushInfo) {
		this.pushInfo = pushInfo;
	}
	
	@Transient
	public String getVideoFlag() {
		return videoFlag;
	}
	public void setVideoFlag(String videoFlag) {
		this.videoFlag = videoFlag;
	}
	@Transient
	public String getHaveNowTagFlag() {
		return haveNowTagFlag;
	}
	public void setHaveNowTagFlag(String haveNowTagFlag) {
		this.haveNowTagFlag = haveNowTagFlag;
	}
	@Transient
	public String getFinishFlag() {
		return finishFlag;
	}
	public void setFinishFlag(String finishFlag) {
		this.finishFlag = finishFlag;
	}
	@Transient
	public String getRegFlag() {
		return regFlag;
	}
	public void setRegFlag(String regFlag) {
		this.regFlag = regFlag;
	}
	
} 
